package com.laiketui.order.mapstruct;

import com.laiketui.order.api.dto.ConfirmOrderDetailDTO;
import com.laiketui.order.api.dto.OrderDetailDTO;
import com.laiketui.order.api.dto.OrderParentMessageDTO;
import com.laiketui.order.domain.OrderDetail;
import com.laiketui.order.domain.OrderParentMessage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Mapper
public interface OrderParentMessageMapstructMapper {
    OrderParentMessageMapstructMapper INSTANCE = Mappers.getMapper(OrderParentMessageMapstructMapper.class);



    OrderParentMessageDTO toDTO(OrderParentMessage message);


    default List<OrderParentMessageDTO> toDTOs(List<OrderParentMessage> orderParents){
        if(CollectionUtils.isEmpty(orderParents)){
            return new ArrayList<>();
        }
        return orderParents.stream().map(this::toDTO).collect(Collectors.toList());
    };
}
